/*
 * @Author: 
 * @Date: 2025-07-30 16:04:57
 * @LastEditor: zhuxiaoyi
 * @LastEditTime: 2025-07-30 16:29:41
 * @Description: 
 */
import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm';
import { ApiProperty } from '@midwayjs/swagger';

@Entity('feedback')
export class Feedback {
  @ApiProperty({ description: '主键ID' })
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ description: '用户ID' })
  @Column({ name: 'user_id', nullable: true, comment: '用户ID' })
  userId?: number;

  @ApiProperty({ description: '用户姓名' })
  @Column({ name: 'user_name', length: 50, nullable: true, comment: '用户姓名' })
  userName?: string;

  @ApiProperty({ description: '联系邮箱' })
  @Column({ name: 'email', length: 100, nullable: true, comment: '联系邮箱' })
  email?: string;

  @ApiProperty({ description: '反馈类型', enum: ['bug', 'feature', 'complaint', 'suggestion', 'other'] })
  @Column({ 
    name: 'feedback_type', 
    type: 'varchar',
    length: 20,
    default: 'suggestion',
    comment: '反馈类型：bug-错误报告, feature-功能建议, complaint-投诉, suggestion-建议, other-其他'
  })
  feedbackType: 'bug' | 'feature' | 'complaint' | 'suggestion' | 'other';

  @ApiProperty({ description: '反馈标题' })
  @Column({ name: 'title', type: 'varchar', length: 200, comment: '反馈标题' })
  title: string;

  @ApiProperty({ description: '反馈内容' })
  @Column({ name: 'content', type: 'text', comment: '反馈内容' })
  content: string;

  @ApiProperty({ description: '优先级', enum: ['low', 'medium', 'high', 'urgent'] })
  @Column({ 
    name: 'priority', 
    type: 'varchar',
    length: 10,
    default: 'medium',
    comment: '优先级：low-低, medium-中, high-高, urgent-紧急'
  })
  priority: 'low' | 'medium' | 'high' | 'urgent';

  @ApiProperty({ description: '处理状态', enum: ['pending', 'processing', 'resolved', 'closed', 'rejected'] })
  @Column({ 
    name: 'status', 
    type: 'varchar',
    length: 15,
    default: 'pending',
    comment: '处理状态：pending-待处理, processing-处理中, resolved-已解决, closed-已关闭, rejected-已拒绝'
  })
  status: 'pending' | 'processing' | 'resolved' | 'closed' | 'rejected';

  @ApiProperty({ description: '处理人ID' })
  @Column({ name: 'handler_id', nullable: true, comment: '处理人ID' })
  handlerId?: number;

  @ApiProperty({ description: '处理备注' })
  @Column({ name: 'handler_remark', type: 'text', nullable: true, comment: '处理备注' })
  handlerRemark?: string;

  @ApiProperty({ description: '处理时间' })
  @Column({ name: 'handled_at', type: 'timestamp', nullable: true, comment: '处理时间' })
  handledAt?: Date;

  @ApiProperty({ description: '是否已读' })
  @Column({ name: 'is_read', type: 'boolean', default: false, comment: '是否已读' })
  isRead: boolean;

  @ApiProperty({ description: '创建时间' })
  @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
  createdAt: Date;

  @ApiProperty({ description: '更新时间' })
  @UpdateDateColumn({ name: 'updated_at', comment: '更新时间' })
  updatedAt: Date;
}
